package eleventh.Random类;

import java.util.Random;

// 最大值到36 所以设置边界值就是37 并且里面不能有0或者是重复的数据
public class 编写36选7的彩票程序 {
    public static void main(String[] args) {
        Random r = new Random();
        //随机7个数字
        int arr [] =new int[7];
     int fool  =0;
     while(fool<7){
         int n = r.nextInt(37);
         if(!repeat(arr,n)){
             arr[fool++]=n;
         }
     }
        java.util.Arrays.sort(arr);//排序
        //判断重复
        for (int i = 0; i <arr.length ; i++) {

            System.out.print(arr[i]+"\t");
        }
    }
    public static boolean repeat(int temp[], int num) {
        if (num == 0) {
            return true;
        }
        for (int i = 0; i < temp.length; i++) {
            if (temp[i] == num) {
                return true;
            }
        }
        return false;
    }
}
/*
D:\WorkSpaces\Java\jdk-21\bin\java.exe "-javaagent:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=56794:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\WorkSpaces\JavaDevelopBase_start_329\out\production\JavaDevelopBase_start_329 eleventh.Random类.编写36选7的彩票程序
3	7	11	13	23	29	30
Process finished with exit code 0

 */